package org.example.coffeeshoporderingsystem.staff.service.impl;

import org.example.coffeeshoporderingsystem.common.service.impl.BaseServiceImpl;
import org.example.coffeeshoporderingsystem.staff.dao.StaffDAO;
import org.example.coffeeshoporderingsystem.staff.entity.Staff;
import org.example.coffeeshoporderingsystem.staff.service.StaffService;
import org.example.coffeeshoporderingsystem.staff.util.StaffUtil;
import org.springframework.stereotype.Service;

@Service
public class StaffServiceImpl extends BaseServiceImpl<Staff, StaffDAO> implements StaffService {
    @Override
    public boolean login(String username, String password) {
        // 根据 账号查询
        Staff staff = baseDAO.selectById(Integer.parseInt(username));
        // 工号  手机号码 后四位 一致则登录成功
        if (staff == null || !staff.getPhoneNumber().substring(staff.getPhoneNumber().length()-4).equals(password)) {
            return false;
        }
        StaffUtil.setStaff(staff);
        // 登录成功
        return true;
    }
}
